package afcp.alumni.dao.impl;

//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import afcp.alumni.dao.RoleDao;
//import afcp.alumni.dao.RolesDao;
//import afcp.alumni.dao.base.DaoDatastore;
//import afcp.alumni.model.base.DatastoreEntity;
//import afcp.alumni.model.db.Ancestor;
//import afcp.alumni.model.db.Role;
//
//@Component
//public class RoleDaoImpl extends DaoDatastore<Role> implements RoleDao {
//
//	private static final Log logger = LogFactory.getLog(RoleDaoImpl.class);
//
//	@Override
//	protected Class<Role> getClassObject() {
//		return Role.class;
//	}
//	
//	private DatastoreEntity rolesAncestor;
//	public static final String ANCESTOR_ID = "ANCESTOR";
//
//	@Override
//	public DatastoreEntity getEntityAncestor() {
////		logger.info("getting roles ancestor");
//		// TODO problème de concurrence ici. Si on peut se passer d'ancêtre
//		// commun (à toutes les requêtes envoyées au site), c'est mieux.
//		synchronized (this) {
//			if (rolesAncestor == null) {
//				logger.info("roles ancestor is null, getting the roles ancestor from datastore.");
//				rolesAncestor = rolesDao.find(ANCESTOR_ID);
//				if (rolesAncestor == null) {
//					logger.info("roles ancestor is not in datastore. Creating Roles entity.");
//					Ancestor ancestor = new Ancestor();
//					rolesAncestor = ancestor;
//					rolesDao.addOrUpdate(ancestor);
//				}
//			}
//		}
//		return rolesAncestor;
//	}
//
////	private RoleDaoImpl() {
////	}
////
////	private static RoleDaoImpl instance = null;
////
////	public static RoleDaoImpl getDao() {
////		if (instance == null) {
////			instance = new RoleDaoImpl();
////		}
////		return instance;
////	}
//	
//	@Autowired
//	private RolesDao rolesDao;
//
////	@Override
////	protected Class<? extends UniqueField<?>> getUniqueFieldClassObject() {
////		return null;
////	}
//	
////	@Override
////	public boolean add(Role entity) {
////		entity.setKey(getEntityAncestor().getKey());
////		return super.add(entity);
////	}
//
//}
